Skip to content

refactor: use typed Prometheus family descriptors#14

Draft
zeitlinger wants to merge 1 commit into
codex/prometheus-translation-strategyfrom
stacked/prometheus-typed-family-descriptor
Draft

refactor: use typed Prometheus family descriptors#14
zeitlinger wants to merge 1 commit into
codex/prometheus-translation-strategyfrom
stacked/prometheus-typed-family-descriptor

Conversation

@zeitlinger
Copy link
Copy Markdown
Owner

@zeitlinger zeitlinger commented May 13, 2026

Blocked by open-telemetry#8346

Summary

Stacked on top of open-telemetry#8346.

This refactors the Prometheus exporter to use the new typed client_java
family descriptor API where the translation strategy already matches typed
Prometheus family semantics.

Depends on:

What changed

  • use MetricFamilyDescriptor for target_info
  • use MetricFamilyDescriptor when deriving metadata for:
    • UNDERSCORE_ESCAPING_WITH_SUFFIXES
    • NO_UTF8_ESCAPING_WITH_SUFFIXES
  • keep the legacy direct MetricMetadata construction paths for the
    no-suffix translation modes for now
  • update the metadata translation test to reflect the typed descriptor-backed
    metadata shape for UTF-8 counter translation

Why

#8346 expands translation-strategy support, but the exporter still manually
constructs Prometheus MetricMetadata in the conversion path.

With client_java#2114, the Prometheus-semantic translation modes can rely on
upstream typed metadata derivation instead of rebuilding those rules locally.

The no-suffix translation modes are intentionally left on the compatibility
path for now because they do not map cleanly to typed counter semantics.

Validation

Tested locally against a locally installed prometheus/client_java
1.6.2-SNAPSHOT containing MetricFamilyDescriptor from
prometheus/client_java#2114:

./gradlew --no-build-cache \
  -I /tmp/otel-prom-local.init.gradle \
  :exporters:prometheus:test \
  --tests io.opentelemetry.exporter.prometheus.Otel2PrometheusConverterTest \
  --tests io.opentelemetry.exporter.prometheus.PrometheusMetricReaderTest \
  --tests io.opentelemetry.exporter.prometheus.PrometheusHttpServerTest

Notes

  • This is a stacked draft for review of the direction, not something expected
    to pass upstream CI before the client_java API lands in a published
    dependency.

Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
@zeitlinger zeitlinger force-pushed the stacked/prometheus-typed-family-descriptor branch from e7e6132 to 725928c Compare May 13, 2026 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant